package com.mrjy.custom.controller;

import com.mrjy.common.entity.UserCoursePackageRel;
import com.mrjy.custom.bo.ICustomModuleBo;
import com.mrjy.custom.dto.CustomModuleDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/custom/module")
public class CustomModuleController {

	@Resource
	private ICustomModuleBo customModuleBo;

	/**
	 * @author Javin
	 * @date 2017年9月7日
	 * @desc 分页查询【精品课】、 use = 微信端1.5课堂
	 * @param module
	 * @return
	 */
	@RequestMapping("/queryPageJPCourse")
	@ResponseBody
	public Object queryPageJPCourse(CustomModuleDto module) {
		return customModuleBo.queryPageJPCourse(module);
	}

	/**
	 * @author Javin
	 * @date 2017年9月7日
	 * @desc 查询免费视频
	 * @param module
	 * @return
	 */
	@RequestMapping("/queryPageFreeVideo")
	@ResponseBody
	public Object queryPageFreeVideo(CustomModuleDto module) {
		return customModuleBo.queryPageFreeVideo(module);
	}
	
	/**
	 * 微信1.5 
	 * 查询自定义模块(cmType:1--精品课  2--免费视频  3--明师课程包) for weixin
	 * @param module
	 * @return
	 */
	@RequestMapping("/queryPageCustomModule")
	@ResponseBody
	public Object queryPageCustomModule(CustomModuleDto module){
		return customModuleBo.queryPageCustomModule(module);
	}

	/**
	 * 添加--后台
	 * 
	 * @return
	 */
	@RequestMapping(value = "/insert", method = RequestMethod.POST)
	@ResponseBody
	public Object insert(CustomModuleDto module,HttpSession session) {
		return	customModuleBo.insert(module,session);
	}

	/**
	 * 根据用户输入关键字模糊查询所有老师
	 * flag=0 所有老师  flag=1 有视频或课程包的老师
	 * @param teacherName
	 * @return
	 */
	@RequestMapping(value = "/queryAllTeacher", method = RequestMethod.POST)
	@ResponseBody
	public Object queryAllTeacher(String teacherName,String flag) {
		return customModuleBo.queryAllTeacher(teacherName,flag);
	}
	

	/**
	 * 根据明师ID查询该明师所有视频
	 * 
	 * @param teacherName
	 * @return
	 */
	@RequestMapping(value = "/queryVideoByTeacher", method = RequestMethod.POST)
	@ResponseBody
	public Object queryVideoByTeacher(String teacherId) {
		return customModuleBo.queryVideoByTeacher(teacherId);
	}

	/**
	 * 分页查询--后台
	 * 
	 * @param recommendTeacher
	 * @return
	 */
	@RequestMapping("/listByPage")
	@ResponseBody
	public Object listByPage(CustomModuleDto module,HttpSession session) {
		return customModuleBo.listByPage(module,session);
	}

	/**
	 * 获取推荐总数
	 * 
	 * @return
	 */
	@RequestMapping("/getTotal")
	@ResponseBody
	public Object getTotal(CustomModuleDto module) {
		return customModuleBo.getTotal(module);
	}

	/**
	 * 启用/禁用
	 * 
	 * @param recommendTeacher
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(CustomModuleDto module,HttpSession session) {
		return	customModuleBo.updateDisableFlag(module,session);
	}

	/**
	 * 修改
	 * 
	 * @param 
	 * @return
	 */
	@RequestMapping("/update")
	@ResponseBody
	public Object update(CustomModuleDto module,HttpSession session) {
		return customModuleBo.updateById(module,session);
	}
	
	/**
	 * 删除
	 * @param 
	 * @return
	 */
	@RequestMapping("/deleteByIds")
	@ResponseBody
	public Object deleteByIds(CustomModuleDto module,HttpSession session){
		return customModuleBo.deleteByIds(module,session);
	}

    /**
     * 添加--后台
     *
     * @return
     */
    @RequestMapping(value = "/insertTopic", method = RequestMethod.POST)
    @ResponseBody
    public Object insertTopic(CustomModuleDto module, HttpSession session) {
        return customModuleBo.insertTopic(module, session);
    }
    
    /**
     * 根据id查询话题相关标签
     * @return
     */
	@RequestMapping("/queryTopicById")
	@ResponseBody
	public Object queryTopicById(CustomModuleDto module,HttpSession session){
		return customModuleBo.queryTopicById(module,session);
	}

    /**
     * 得到当前用户个话题的完成情况
     *
     * @param info
     * @return
     */
    @RequestMapping("/querySummaryByUserId")
    @ResponseBody
    public Object querySummaryByUserId(CustomModuleDto customModuleDto) {
        return customModuleBo.querySummaryByUserId(customModuleDto);
    }

    /**
     * 家长合格证
     *
     * @param info
     * @return
     */
    @RequestMapping("/queryParentCertificationByUserId")
    @ResponseBody
    public Object queryParentCertificationByUserId(CustomModuleDto customModuleDto, HttpSession session) {
        return customModuleBo.queryParentCertificationByUserId(customModuleDto, session);
    }

    /**
     * 得到当前用户个话题以及相关信息
     *
     * @param info
     * @return
     */
    @RequestMapping("/queryCustomTopicInfoByUserId")
    @ResponseBody
    public Object queryCustomTopicInfoByUserId(UserCoursePackageRel userCoursePackageRel, HttpSession session) {
        return customModuleBo.queryCustomTopicInfoByUserId(userCoursePackageRel, session);
    }
}
